package com.docman.controller;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.docman.dao.TagDAO;
import com.docman.domainmodel.TagBean;
import com.docman.domainmodel.UniversityBean;


@WebServlet("/GetTagServlet")
public class GetTagServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
    public GetTagServlet() {
        super();
        
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("text/html;  charset=utf-8");
		request.setCharacterEncoding("UTF-8");
		
		String siteType = request.getParameter("sId");
			
		ArrayList<TagBean> tags = new ArrayList<TagBean>();
		
		tags=TagDAO.getTags();
		
		request.setAttribute("tagList", tags);
		
		RequestDispatcher dispatcher = null;
		
		if(siteType.equals("0")){		
			dispatcher = getServletContext().getRequestDispatcher("/fileUpload.jsp");
		}else {
			dispatcher = getServletContext().getRequestDispatcher("/advanceSearch.jsp");
		}
		if (dispatcher != null){
			 
		  dispatcher.forward(request, response);

		  }
		 else{
			 System.out.println("Disp null");
		 }
		
	}

}
